import ImageUploader from "./ImageUpload";

export default class DefaultImageUpload implements ImageUploader{

    async upload(image: File, uploadAddress: string): Promise<string> {
        const requestData = new FormData();
        requestData.append("file", image);
        
        const res = await fetch(uploadAddress, {
          method: "POST",
          body: requestData,
        });
    
        if (!res.ok) {
            throw new Error(await res.text());
        }
        return await res.text();
    }

}